<?php

function __autoload($class_name){
    require_once "./$class_name.php";
}

/***************************************************************************
 * Tablas:
 *      Autores:
 *      Comics:
 *      Galerias:
 *
 */
class FenixTreceComicsPage extends Controller{
    function __construct(){
        $this->styles_files = array('fenix');
        $this->javascript_files = array();
    }

    function index(){
        $this->title = 'Un titulo';
        $this->page_title = 'Que lindo titulo';
        
        // Primero pedimos los rss
        require_once('../MagpiesRSS/rss_fetch.inc');
        $url = 'http://my.opera.com/anibal784/xml/rss/blog/';
        $this->rss_anibal = fetch_rss($url);
        $this->rss_anibal->items = array_slice($this->rss_anibal->items, 0, 3);

        $url = 'http://fenixtrececomics.blogspot.com/feeds/posts/default';
        $this->rss_adrian = fetch_rss($url);
        $this->rss_adrian->items = array_slice($this->rss_adrian->items, 0, 3);

        // Ultimo comic subido
        $db = Driver_MySQL::sharedDriver();
        $ultimo = array('limit' => 1, 'offset' => 0,
                        'order_by' => 'id desc');
        $this->ultimo_comic = $db->select_from('Comics', '*', $ultimo);
        $this->ultimo_comic_guion = $db->select_from('Comics, Autores', 'Autores.nombres, Autores.apellido',
                                                     array('where' => $this->ultimo_comic->guion.'= Autores.id'));
        $this->ultimo_comic_tinta = $db->select_from('Comics, Autores', 'Autores.nombres, Autores.apellido',
                                                     array('where' => $this->ultimo_comic->tinta.'= Autores.id'));
        $this->ultimo_comic_dibujos = $db->select_from('Comics, Autores', 'Autores.nombres, Autores.apellido',
                                                     array('where' => $this->ultimo_comic->dibujos.'= Autores.id'));
        $this->comics = $db->select_from('Comics', 'nombre');

        /**
         * Consulta SQL para pedir las ultimas imagenes de cada autor
         * SELECT * FROM aux WHERE id IN ( SELECT max(id) FROM aux group by fk);
         */
    }
}

/*
$db = Driver_MySQL::sharedDriver();
$ultimo = array('limit' => 1, 'offset' => 0,
                    'order_by' => 'id desc');
$ultimo_comic = $db->select_from('Comics', '*', $ultimo);
$ultimo_comic_guion = $db->select_from('Comics, Autores', 'Autores.nombres, Autores.apellido',
                                             array('where' => "1 = Autores.id"));
echo $ultimo_comic_guion->nombres, "<br />", $ultimo_comic_guion->apellido;
exit;
*/
$a = new FenixTreceComicsPage();
$method = 'index';
if(isset($_GET['method']) && $_GET['method'] != null){
    $method = $_GET['method'];
}

$a->yield_page($method);

?>
